<?php
require_once(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR ."core".DIRECTORY_SEPARATOR."functions.php");
core::getResource("Model.Register");
core::getResource("Controller.baseController");
class RegisterController extends baseController
{	
	private $email,$password;
	private $regger;//model class
	public function __construct($firstName,$lastName,$email,$password,$gender,$contactNumber,$accountType=ACC_VOLUNTEER)
	{
		$this->regger = new Register($firstName,$lastName,$email,$password,$gender,$contactNumber,$accountType=ACC_VOLUNTEER);
	}
	
	public function register()
	{
		if($this->regger->pass())
		{
			//email does not already exist in the database
			if($this->regger->finish())
			{
				//registration finished
				return REGISTER_SUCCESS;
			}
			else
			{
				//could not insert into the database
				return REG_ERR;
			}
		}
		else
		{
			//email already exists in the database
			return REG_ERR_EMAIL;
		}
	}

	public function getId()
	{
		return $this->regger->getId();
	}

	public function getActivationKey()
	{
		return $this->regger->getActivationKey();
	}
}

?>